package components;

import java.awt.Toolkit;

import support.Program;

public class Programator {

	private Program selectedProgram;

	private int selectedTemperature;
	private int selectedRounds;
	private int selectedTime;

	private boolean isProgramSelected = false;

	public boolean isProgramSelected() {
		return isProgramSelected;
	}

	public void setProgramSelected(boolean isProgramSelected) {
		this.isProgramSelected = isProgramSelected;
	}

	public void changeTemperature() {
		if (selectedProgram.isModificable()) {
			if (selectedTemperature == selectedProgram.getMaxTemp()) {
				selectedTemperature = selectedProgram.getMinTemp();
			} else {
				selectedTemperature = +10;
			}

		} else {
			Toolkit.getDefaultToolkit().beep();
		}
	}

	public void changeRounds() {
		if (selectedProgram.isModificable()) {
			if (selectedRounds == selectedProgram.getMaxRounds()) {
				selectedRounds = selectedProgram.getMinRounds();
			} else {
				selectedRounds = +100;
			}

		} else {
			Toolkit.getDefaultToolkit().beep();
		}
	}

	public int getRounds() {
		return selectedRounds;
	}

	public int getTime() {
		return selectedTime;
	}

	public int getTemperature() {
		return selectedTemperature;
	}

	public void setProgram(Program program) {
		selectedProgram = program;
		isProgramSelected = true;
		selectedTemperature = program.getDefaultTemperature();
		selectedRounds = program.getDefaultRounds();
		selectedTime = program.getDefaultTime();
	}

	public Program getSelectedProgram() {
		return selectedProgram;
	}
	
}
